package my.download;

import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;
import java.time.temporal.TemporalUnit;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class BrowserManager {

    public void operateChrome() {
        WebDriverManager.chromedriver().setup();
        WebDriver driver = new ChromeDriver();
        driver.get("https://finance-ht-ccms.hxfintec.com/ccms-app/fastDevelop/process.htm?code=login&fromUrl=http%3A%2F%2Ffinance-ht-ccms.hxfintec.com%2Fccms-app%2FfastDevelop%2Fprocess.htm");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        Set<Cookie> cookies = driver.manage().getCookies();
        for (Cookie cookie : cookies) {
            System.out.println(cookie.getName() + "=" + cookie.getValue());
        }
//        String pwd = sc.nextLine();
//        String code = sc.nextLine();
//        driver.switchTo().frame("tabs4");
//        List<WebElement> elementList = driver.findElements(By.cssSelector(".ng-scope .ng-binding"));
//        for (String handle : driver.getWindowHandles()) {
//            System.out.println(handle);
//            driver.switchTo().window(handle);
//        }
//        for (WebElement element : elementList) {
//            String href = element.getAttribute("href");
//            System.out.println(href);
//            if (href != null && href.endsWith("#/core/tblCcmsLogCaseRemarkdy")) {
//
//            }
//        }
        driver.close();
    }

    public static void main(String[] args) {
        new BrowserManager().operateChrome();
    }
}
